package com.dq.library.stringutil;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class StringUtil {

	public static void main(String[] args) {
		/*String string="RPT,RPT000,RPT100,RPT130,RPT110,RPT120,RPT160,RPT140,RPT150,RPT170,RPT180,RPT190,RCT000,RCD000";
		String auths[];
           
		auths=string.split("\\,");
		
		for (int i = 0; i < auths.length; i++) {
			System.out.println(auths[i]);
		}
		String auths1[]={"RPT100","RPT160"};
		List list=Arrays.asList(auths);
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
		String aa[]=(String[])list.toArray();
		for (int i = 0; i < aa.length; i++) {
			System.out.println(aa[i]);
		}*/
		
			/*String string="RPT,RPT000,RPT100,RPT130,RPT110,RPT120,RPT160,RPT140,RPT150,RPT170,RPT180,RPT190,RCT000,RCD000";
			String auths[];
			String auths1[]={"RPT100","RPT160"};
			
			auths=string.split("\\,");
			System.out.println(string);
			Object ss[]=StringUtil.deleteArrayElement(auths, auths1);
			for (int i = 0; i < ss.length; i++) {
				System.out.print(ss[i]+",");
			}*/
		String authString="RPT130,RPT110";
		String nodeLIst="RPT130,RPT110,RPT120, RPT160, RPT140, RPT150, RPT170, RPT180, RPT190";
		String authSysString="RPT,RPT000,RPT100,RPT130,RPT110,RPT120,RPT160,RPT150,RPT170,RPT180,RPT190,RCT000,RCD000";
		//RPT120, RPT160, RPT140, RPT150, RPT170, RPT180, RPT190
	    Object ss[]=StringUtil.deleteArrayElement(nodeLIst.split("\\,"), authString.split("\\,"));
		String s1[]=new String[ss.length];
		for (int i = 0; i < ss.length; i++) {
			s1[i]=ss[i].toString();
		}
		for (int i = 0; i < s1.length; i++) {
			System.out.print(s1[i].trim()+",");
		}
		System.out.println();
		List list=StringUtil.getList(s1);
		
		System.out.println(list.size());
		
		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i).toString()+",");
		}
		
		for (int i = 0; i < list.size(); i++) {
			if(!authSysString.contains(list.get(i).toString().trim())){
				list.remove(list.get(i).toString().trim());
			}
		}
		System.out.println(list.size());
		
		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i).toString()+",");
		}
		
	}
	
	
	/*public class TransferStrAry { 
		public static void main(String[] args) { 
			List list = new ArrayList();
			list.add("asdfasdf");
			list.add("sfh");
			list.add("345");
			String[] str =new String[list.size()];
			list.toArray(str); 
			for(String s:str){
				System.out.println(s); }
			} }*/
	
	
	public static List getList(String string){
		
		List<String> test = new ArrayList<String>();  
		for(String t : string.split(",")){  
		        test.add(t);  
		}  
		return test;
	}
    public static List getList(String[] string){
		
		List<String> test = new ArrayList<String>();  
		for(String t : string){  
		        test.add(t.trim());  
		}  
		return test;
	}
	
	public static Object[] deleteArrayElement(String[] string,String[] string1){
		List list=Arrays.asList(string);
		List l=new ArrayList();
		l.addAll(list);
		
		for (int i = 0; i < l.size(); i++) 
		{
			for (int j = 0; j < string1.length; j++) 
			{
				if(l.get(i).equals(string1[j]))
				{
					l.remove(i);
				}
			}
			
		}
		return l.toArray();
	}
}
